package com.abc.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
*
*  @author luo
*/
public class Swiper implements Serializable {

    private static final long serialVersionUID = 1539868551459L;


    /**
    * 主键
    * 
    * isNullAble:0
    */
    private Integer id;

    /**
    * 
    * isNullAble:1
    */
    private String title;

    /**
    * 
    * isNullAble:1
    */
    private Integer uploadId;

    /**
    * 
    * isNullAble:1,defaultVal:1
    */
    private Integer order;

    /**
    * 
    * isNullAble:1,defaultVal:0
    */
    private Integer status;


    public void setId(Integer id){this.id = id;}

    public Integer getId(){return this.id;}

    public void setTitle(String title){this.title = title;}

    public String getTitle(){return this.title;}

    public void setUploadId(Integer uploadId){this.uploadId = uploadId;}

    public Integer getUploadId(){return this.uploadId;}

    public void setOrder(Integer order){this.order = order;}

    public Integer getOrder(){return this.order;}

    public void setStatus(Integer status){this.status = status;}

    public Integer getStatus(){return this.status;}
    @Override
    public String toString() {
        return "Swiper{" +
                "id='" + id + '\'' +
                "title='" + title + '\'' +
                "uploadId='" + uploadId + '\'' +
                "order='" + order + '\'' +
                "status='" + status + '\'' +
            '}';
    }

    public static Builder Build(){return new Builder();}

    public static ConditionBuilder ConditionBuild(){return new ConditionBuilder();}

    public static UpdateBuilder UpdateBuild(){return new UpdateBuilder();}

    public static QueryBuilder QueryBuild(){return new QueryBuilder();}

    public static class UpdateBuilder {

        private Swiper set;

        private ConditionBuilder where;

        public UpdateBuilder set(Swiper set){
            this.set = set;
            return this;
        }

        public Swiper getSet(){
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where){
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere(){
            return this.where;
        }

        public UpdateBuilder build(){
            return this;
        }
    }

    public static class QueryBuilder extends Swiper{
        /**
        * 需要返回的列
        */
        private Map<String,Object> fetchFields;

        public Map<String,Object> getFetchFields(){return this.fetchFields;}

        private List<Integer> idList;

        public List<Integer> getIdList(){return this.idList;}

        private Integer idSt;

        private Integer idEd;

        public Integer getIdSt(){return this.idSt;}

        public Integer getIdEd(){return this.idEd;}

        private List<String> titleList;

        public List<String> getTitleList(){return this.titleList;}


        private List<String> fuzzyTitle;

        public List<String> getFuzzyTitle(){return this.fuzzyTitle;}

        private List<String> rightFuzzyTitle;

        public List<String> getRightFuzzyTitle(){return this.rightFuzzyTitle;}
        private List<Integer> uploadIdList;

        public List<Integer> getUploadIdList(){return this.uploadIdList;}

        private Integer uploadIdSt;

        private Integer uploadIdEd;

        public Integer getUploadIdSt(){return this.uploadIdSt;}

        public Integer getUploadIdEd(){return this.uploadIdEd;}

        private List<Integer> orderList;

        public List<Integer> getOrderList(){return this.orderList;}

        private Integer orderSt;

        private Integer orderEd;

        public Integer getOrderSt(){return this.orderSt;}

        public Integer getOrderEd(){return this.orderEd;}

        private List<Integer> statusList;

        public List<Integer> getStatusList(){return this.statusList;}

        private Integer statusSt;

        private Integer statusEd;

        public Integer getStatusSt(){return this.statusSt;}

        public Integer getStatusEd(){return this.statusEd;}

        private QueryBuilder (){
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder idBetWeen(Integer idSt,Integer idEd){
            this.idSt = idSt;
            this.idEd = idEd;
            return this;
        }

        public QueryBuilder idGreaterEqThan(Integer idSt){
            this.idSt = idSt;
            return this;
        }
        public QueryBuilder idLessEqThan(Integer idEd){
            this.idEd = idEd;
            return this;
        }


        public QueryBuilder id(Integer id){
            setId(id);
            return this;
        }

        public QueryBuilder idList(Integer ... id){
            this.idList = solveNullList(id);
            return this;
        }

        public QueryBuilder idList(List<Integer> id){
            this.idList = id;
            return this;
        }

        public QueryBuilder fetchId(){
            setFetchFields("fetchFields","id");
            return this;
        }

        public QueryBuilder excludeId(){
            setFetchFields("excludeFields","id");
            return this;
        }

        public QueryBuilder fuzzyTitle (List<String> fuzzyTitle){
            this.fuzzyTitle = fuzzyTitle;
            return this;
        }

        public QueryBuilder fuzzyTitle (String ... fuzzyTitle){
            this.fuzzyTitle = solveNullList(fuzzyTitle);
            return this;
        }

        public QueryBuilder rightFuzzyTitle (List<String> rightFuzzyTitle){
            this.rightFuzzyTitle = rightFuzzyTitle;
            return this;
        }

        public QueryBuilder rightFuzzyTitle (String ... rightFuzzyTitle){
            this.rightFuzzyTitle = solveNullList(rightFuzzyTitle);
            return this;
        }

        public QueryBuilder title(String title){
            setTitle(title);
            return this;
        }

        public QueryBuilder titleList(String ... title){
            this.titleList = solveNullList(title);
            return this;
        }

        public QueryBuilder titleList(List<String> title){
            this.titleList = title;
            return this;
        }

        public QueryBuilder fetchTitle(){
            setFetchFields("fetchFields","title");
            return this;
        }

        public QueryBuilder excludeTitle(){
            setFetchFields("excludeFields","title");
            return this;
        }

        public QueryBuilder uploadIdBetWeen(Integer uploadIdSt,Integer uploadIdEd){
            this.uploadIdSt = uploadIdSt;
            this.uploadIdEd = uploadIdEd;
            return this;
        }

        public QueryBuilder uploadIdGreaterEqThan(Integer uploadIdSt){
            this.uploadIdSt = uploadIdSt;
            return this;
        }
        public QueryBuilder uploadIdLessEqThan(Integer uploadIdEd){
            this.uploadIdEd = uploadIdEd;
            return this;
        }


        public QueryBuilder uploadId(Integer uploadId){
            setUploadId(uploadId);
            return this;
        }

        public QueryBuilder uploadIdList(Integer ... uploadId){
            this.uploadIdList = solveNullList(uploadId);
            return this;
        }

        public QueryBuilder uploadIdList(List<Integer> uploadId){
            this.uploadIdList = uploadId;
            return this;
        }

        public QueryBuilder fetchUploadId(){
            setFetchFields("fetchFields","uploadId");
            return this;
        }

        public QueryBuilder excludeUploadId(){
            setFetchFields("excludeFields","uploadId");
            return this;
        }

        public QueryBuilder orderBetWeen(Integer orderSt,Integer orderEd){
            this.orderSt = orderSt;
            this.orderEd = orderEd;
            return this;
        }

        public QueryBuilder orderGreaterEqThan(Integer orderSt){
            this.orderSt = orderSt;
            return this;
        }
        public QueryBuilder orderLessEqThan(Integer orderEd){
            this.orderEd = orderEd;
            return this;
        }


        public QueryBuilder order(Integer order){
            setOrder(order);
            return this;
        }

        public QueryBuilder orderList(Integer ... order){
            this.orderList = solveNullList(order);
            return this;
        }

        public QueryBuilder orderList(List<Integer> order){
            this.orderList = order;
            return this;
        }

        public QueryBuilder fetchOrder(){
            setFetchFields("fetchFields","order");
            return this;
        }

        public QueryBuilder excludeOrder(){
            setFetchFields("excludeFields","order");
            return this;
        }

        public QueryBuilder statusBetWeen(Integer statusSt,Integer statusEd){
            this.statusSt = statusSt;
            this.statusEd = statusEd;
            return this;
        }

        public QueryBuilder statusGreaterEqThan(Integer statusSt){
            this.statusSt = statusSt;
            return this;
        }
        public QueryBuilder statusLessEqThan(Integer statusEd){
            this.statusEd = statusEd;
            return this;
        }


        public QueryBuilder status(Integer status){
            setStatus(status);
            return this;
        }

        public QueryBuilder statusList(Integer ... status){
            this.statusList = solveNullList(status);
            return this;
        }

        public QueryBuilder statusList(List<Integer> status){
            this.statusList = status;
            return this;
        }

        public QueryBuilder fetchStatus(){
            setFetchFields("fetchFields","status");
            return this;
        }

        public QueryBuilder excludeStatus(){
            setFetchFields("excludeFields","status");
            return this;
        }
        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll(){
            this.fetchFields.put("AllFields",true);
            return this;
        }

        public QueryBuilder addField(String ... fields){
            List<String> list = new ArrayList<>();
            if (fields != null){
                for (String field : fields){
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields",list);
            return this;
        }
        @SuppressWarnings("unchecked")
        private void setFetchFields(String key,String val){
            Map<String,Boolean> fields= (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null){
                fields = new HashMap<>();
            }
            fields.put(val,true);
            this.fetchFields.put(key,fields);
        }

        public Swiper build(){return this;}
    }


    public static class ConditionBuilder{
        private List<Integer> idList;

        public List<Integer> getIdList(){return this.idList;}

        private Integer idSt;

        private Integer idEd;

        public Integer getIdSt(){return this.idSt;}

        public Integer getIdEd(){return this.idEd;}

        private List<String> titleList;

        public List<String> getTitleList(){return this.titleList;}


        private List<String> fuzzyTitle;

        public List<String> getFuzzyTitle(){return this.fuzzyTitle;}

        private List<String> rightFuzzyTitle;

        public List<String> getRightFuzzyTitle(){return this.rightFuzzyTitle;}
        private List<Integer> uploadIdList;

        public List<Integer> getUploadIdList(){return this.uploadIdList;}

        private Integer uploadIdSt;

        private Integer uploadIdEd;

        public Integer getUploadIdSt(){return this.uploadIdSt;}

        public Integer getUploadIdEd(){return this.uploadIdEd;}

        private List<Integer> orderList;

        public List<Integer> getOrderList(){return this.orderList;}

        private Integer orderSt;

        private Integer orderEd;

        public Integer getOrderSt(){return this.orderSt;}

        public Integer getOrderEd(){return this.orderEd;}

        private List<Integer> statusList;

        public List<Integer> getStatusList(){return this.statusList;}

        private Integer statusSt;

        private Integer statusEd;

        public Integer getStatusSt(){return this.statusSt;}

        public Integer getStatusEd(){return this.statusEd;}


        public ConditionBuilder idBetWeen(Integer idSt,Integer idEd){
            this.idSt = idSt;
            this.idEd = idEd;
            return this;
        }

        public ConditionBuilder idGreaterEqThan(Integer idSt){
            this.idSt = idSt;
            return this;
        }
        public ConditionBuilder idLessEqThan(Integer idEd){
            this.idEd = idEd;
            return this;
        }


        public ConditionBuilder idList(Integer ... id){
            this.idList = solveNullList(id);
            return this;
        }

        public ConditionBuilder idList(List<Integer> id){
            this.idList = id;
            return this;
        }

        public ConditionBuilder fuzzyTitle (List<String> fuzzyTitle){
            this.fuzzyTitle = fuzzyTitle;
            return this;
        }

        public ConditionBuilder fuzzyTitle (String ... fuzzyTitle){
            this.fuzzyTitle = solveNullList(fuzzyTitle);
            return this;
        }

        public ConditionBuilder rightFuzzyTitle (List<String> rightFuzzyTitle){
            this.rightFuzzyTitle = rightFuzzyTitle;
            return this;
        }

        public ConditionBuilder rightFuzzyTitle (String ... rightFuzzyTitle){
            this.rightFuzzyTitle = solveNullList(rightFuzzyTitle);
            return this;
        }

        public ConditionBuilder titleList(String ... title){
            this.titleList = solveNullList(title);
            return this;
        }

        public ConditionBuilder titleList(List<String> title){
            this.titleList = title;
            return this;
        }

        public ConditionBuilder uploadIdBetWeen(Integer uploadIdSt,Integer uploadIdEd){
            this.uploadIdSt = uploadIdSt;
            this.uploadIdEd = uploadIdEd;
            return this;
        }

        public ConditionBuilder uploadIdGreaterEqThan(Integer uploadIdSt){
            this.uploadIdSt = uploadIdSt;
            return this;
        }
        public ConditionBuilder uploadIdLessEqThan(Integer uploadIdEd){
            this.uploadIdEd = uploadIdEd;
            return this;
        }


        public ConditionBuilder uploadIdList(Integer ... uploadId){
            this.uploadIdList = solveNullList(uploadId);
            return this;
        }

        public ConditionBuilder uploadIdList(List<Integer> uploadId){
            this.uploadIdList = uploadId;
            return this;
        }

        public ConditionBuilder orderBetWeen(Integer orderSt,Integer orderEd){
            this.orderSt = orderSt;
            this.orderEd = orderEd;
            return this;
        }

        public ConditionBuilder orderGreaterEqThan(Integer orderSt){
            this.orderSt = orderSt;
            return this;
        }
        public ConditionBuilder orderLessEqThan(Integer orderEd){
            this.orderEd = orderEd;
            return this;
        }


        public ConditionBuilder orderList(Integer ... order){
            this.orderList = solveNullList(order);
            return this;
        }

        public ConditionBuilder orderList(List<Integer> order){
            this.orderList = order;
            return this;
        }

        public ConditionBuilder statusBetWeen(Integer statusSt,Integer statusEd){
            this.statusSt = statusSt;
            this.statusEd = statusEd;
            return this;
        }

        public ConditionBuilder statusGreaterEqThan(Integer statusSt){
            this.statusSt = statusSt;
            return this;
        }
        public ConditionBuilder statusLessEqThan(Integer statusEd){
            this.statusEd = statusEd;
            return this;
        }


        public ConditionBuilder statusList(Integer ... status){
            this.statusList = solveNullList(status);
            return this;
        }

        public ConditionBuilder statusList(List<Integer> status){
            this.statusList = status;
            return this;
        }

        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build(){return this;}
    }

    public static class Builder {

        private Swiper obj;

        public Builder(){
            this.obj = new Swiper();
        }

        public Builder id(Integer id){
            this.obj.setId(id);
            return this;
        }
        public Builder title(String title){
            this.obj.setTitle(title);
            return this;
        }
        public Builder uploadId(Integer uploadId){
            this.obj.setUploadId(uploadId);
            return this;
        }
        public Builder order(Integer order){
            this.obj.setOrder(order);
            return this;
        }
        public Builder status(Integer status){
            this.obj.setStatus(status);
            return this;
        }
        public Swiper build(){return obj;}
    }

}
